﻿	CREATE TABLE public.unit
	(
	    /***************************************************************************************************
	    **  Table:	    public.unit
	    **  Author:		Zhixian Ong
	    **
	    **  Description:
	    **    
	    **    Represents a registered unit.
	    **
	    **  Fields (2):
	    **
	    **      id              - 
	    **      full_name       -
	    **      display_name    -
	    **      nationality_id  -
	    **
	    **  Constaints (2):
	    **
	    **      building_pk - 
	    **      name_uc     -
	    **
	    **  Modification History:
	    **
	    **      20140102  Zhixian Ong     - Initial prototype
	    ** 
	    **  Status:
	    **      Dev
	    ** 
	    ***************************************************************************************************/
        
	    -- [Fields]
	    id              character varying(36)   NOT NULL DEFAULT nextval('unit_id_seq'),
	    building_id     character varying(36)   NOT NULL, 
	    full_name       character varying(128)  NOT NULL,
	    display_name    character varying(128)  NOT NULL,
	    layout_type     character varying(36)   NOT NULL,
	    area            real                    NOT NULL,
	    cost_price      money                   NOT NULL,
	    selling_price   money                   NOT NULL,
	            
	    
        
	    -- [Constraints]
	    CONSTRAINT unit_pk      PRIMARY KEY ("id"),
	    CONSTRAINT unit_name_uc UNIQUE ("building_id", "full_name")
	);